<?php

namespace App\Http\Controllers;

use App\Http\Service\CommentreportService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Config;
## 评论区举报

class CommentreportController extends BaseController
{
    private $getRules=[
            'unique_id'=> 'required',
            'people_id'=> 'required',
            'content'=> 'required',
        ];
    private  $getRulesMessage=[
            'unique_id.required'=> '唯一标识【unique_id】不能为空',
            'people_id.required'=> '用户id【people_id】不能为空',
            'content.required'=> '回复内容【content】不能为空',
        ];
    public $repository;
    #统计评论区的点赞和踩的数量
    public function __construct(CommentreportService $repository)
    {
        parent::__construct();
        $this->repository = $repository;
    }
    public function getList(Request $request)
    {
        $data=[
            'type'=>$request->input("type"),
        ];
        $this->success($this->repository->getList($request,$data));
    }
    #评论区举报列表
    public function commentreportlist(Request $request)
    {
        $data=[
            'user_id'=>$request->json("user_id"),
            'keyword'=>$request->json("keyword"),
        ];
        $this->success($this->repository->commentreportlist($request,$data));
    }

    #评论区举报修改
    public function commentreportedit(Request $request)
    {
        $data=[
            'id'=>$request->json("id"),
            'comment_id'=>$request->json("comment_id"),
            'report_type'=>$request->json("report_type"),
            'user_id'=>$request->json("user_id"),
            'report_reason'=>$request->json("report_reason"),
            'report_evidence'=>$request->json("report_evidence"),
        ];
        if($data['report_evidence']=='[]'){
            $data['report_evidence']=[];
        }
        if(empty($data['report_evidence'])){
            $data['report_evidence']=[];
        }
        if(!is_array($data['report_evidence'])){
            $this->error("【report_evidence】 不是数组");
        }
        $data['report_evidence']=json_encode($data['report_evidence'], JSON_UNESCAPED_UNICODE);

        $this->success($this->repository->commentreportedit($request,$data));
    }
   
    #评论区举报添加
    public function commentreportadd(Request $request)
    {
        $data=[
            'comment_id'=>$request->json("comment_id"),
            'report_type'=>$request->json("report_type"),
            'user_id'=>$request->json("user_id"),
            'report_reason'=>$request->json("report_reason"),
            'report_evidence'=>$request->json("report_evidence"),
        ];
        if($data['report_evidence']=='[]'){
            $data['report_evidence']=[];
        }
        if(empty($data['report_evidence'])){
            $data['report_evidence']=[];
        }
        if(!is_array($data['report_evidence'])){
            $this->error("【report_evidence】 不是数组");
        }
        $data['report_evidence']=json_encode($data['report_evidence'], JSON_UNESCAPED_UNICODE);

        $this->success($this->repository->commentreportadd($request,$data));

    }
   
  

}
